/**
 *  Copyright � 2010 Digia Plc
 *  Copyright � 2010 Nokia Corporation
 *
 *  All rights reserved.
 *
 *  Nokia and Nokia Connecting People are registered trademarks of
 *  Nokia Corporation.
 *  Java and all Java-based marks are trademarks or registered
 *  trademarks of
 *  Sun Microsystems, Inc. Other product and company names
 *  mentioned herein may be
 *  trademarks or trade names of their respective owners.
 *
 *
 *  Subject to the conditions below, you may, without charge:
 *
 *  �  Use, copy, modify and/or merge copies of this software and
 *     associated documentation files (the "Software")
 *
 *  �  Publish, distribute, sub-licence and/or sell new software
 *     derived from or incorporating the Software.
 *
 *
 *  This file, unmodified, shall be included with all copies or
 *  substantial portions
 *  of the Software that are distributed in source code form.
 *
 *  The Software cannot constitute the primary value of any new
 *  software derived
 *  from or incorporating the Software.
 *
 *  Any person dealing with the Software shall not misrepresent
 *  the source of the Software.
 *
 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
 *  KIND, EXPRESS OR IMPLIED,
 *  INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 *  MERCHANTABILITY, FITNESS FOR A
 *  PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 *  AUTHORS OR COPYRIGHT
 *  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 *  WHETHER IN AN ACTION
 *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 *  CONNECTION WITH THE
 *  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
import Qt 4.7
import "styles"
import "../colibri"

Rectangle {
    id: houseRoom

    property string room: "room1"
    property string text: "Bedroom 1"
    property bool doReload: true
    property real hudOpacity: 1
    property CLStyle style: StyleHomeControlSystem {}


    signal clicked( string theRoomCode )

    /**
     * Hides highlight element
     *
     * @return Nothing
     */
    function hideBlur() {
        blurArea.opacity = 0;
        houseRoom.doReload = true;
        houseRoom.hudOpacity = 1;
    }

    /**
     * Shows highlight element
     *
     * @return Nothing
     */
    function showBlur() {
        blurArea.opacity = 0.3;
    }

    /**
     * Hides icon HUD
     *
     * @return Nothing
     */
    function hideHUD() {
        houseRoom.doReload = false;
        houseRoom.hudOpacity = 0;
    }

    clip: true
    color: "transparent"

    Behavior on hudOpacity { PropertyAnimation { target: houseRoom; property: "hudOpacity"; duration: 300; easing.type: Easing.InOutQuad; } }

    Rectangle {
        id: blurArea
        opacity: 0
        anchors.fill: parent
        clip: true
        color: "white"
        Behavior on opacity { PropertyAnimation { target: blurArea; property: "opacity"; duration: 300; easing.type: Easing.InOutQuad; } }
    }

    Column {
        anchors.centerIn: parent;
        spacing: 5
        opacity: houseRoom.hudOpacity

        Text {
            text: houseRoom.text
            font.bold: true
            font.pixelSize: 18
            color: houseRoom.style.textColor
            anchors.horizontalCenter: parent.horizontalCenter
        }

        IconHUD { room: houseRoom.room; doReload: houseRoom.doReload; anchors.horizontalCenter: parent.horizontalCenter; }
    }

    MouseArea {
        anchors.fill: parent
        onClicked: {
            houseRoom.clicked(houseRoom.room);
            houseRoom.showBlur();
        }
    }
}
